package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.WeiChatDto;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//Controller:将此类标识为一个控制器，用来接收用户的请求
@Controller
public class UserController {
    @RequestMapping(value = "/v1/users/login")
    @ResponseBody
    public String login() {
        return "恭喜，生了，女孩,好耶！！！";
    }
    //http://localhost:8080/v1/users/reg%EF%BC%9Fusername=yinghuochong&password=123456
    @RequestMapping(value = "/v1/users/reg")
    @ResponseBody
    public String reg(HttpServletRequest request){
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        return username+"-"+password;
    }
    @RequestMapping(value = "/v1/users/changepwd")
    @ResponseBody
    public String changepwd(String username, String newpwd){
        return username+"-"+newpwd;
    }
    @RequestMapping(value ="/v1/users/weiChat")
    @ResponseBody
    public String weiChat(WeiChatDto weiChatDto){
        String name = weiChatDto.getName();
        String pwd = weiChatDto.getPwd();
        return name+":"+pwd;

    }
}
